^Dog Matches Dog only if it is at the beginning of a line
Moose$ Matches Moose only if it is at the end of a line
Pa*d Matches Pd, Pad, Paad, Paaad etc.
</hl>
<a name="ASTERISK"><h2>Using the Asterisk</h2>
The last example given above uses the * character to indicate zero, one or more occurrences of a particular character ù in this case, the letter 'a'. This is <b>different</b> from the way the Windows operating system uses the * wildcard character. In Windows, the * wildcard matches "any single character".
In regular expressions, however, the asterisk is specific about what you are looking for. That is why 'Pa*d' would not match 'Parsed'; the asterisk means "match zero or more of the preceding character specification".
If you actually want to search for 'Pa' followed by one or more letters and then 'd', the correct syntax is:
<hl> Pa[a-z][a-z]*d</hl>
This means that we want to match 'Pa', then a letter in the range from 'a' to 'z', then some number (including zero) of characters in the 'a' to 'z' range, and finally the letter 'd'. The character string 'Parsed' would meet these criteria, as would 'Pad', 'Paid' and 'Packed'.
[0-9][0-9]* Matches numbers such as 0, 1, 01, 10, 25, 0990, 9999 etc.
-[0-9][0-9]* Matches negative numbers such as -0, -1, -19, -12345 etc.
</hl>
In the last example, [0-9] is specified twice to ensure that at least one digit is found. Bear in mind that the * character means "zero or more occurrences". If you had only specified '-[0-9]*' you would get a spurious match within the string 'Hello - there', since the '-' character is indeed found, followed by <b>zero</b> occurrences of the digits 0 through 9.
You can create fairly complex patterns using regular expressions. Consider this example:
<hl> \$[0-9][0-9]*\.[0-9][0-9]</hl>
This would match dollar amounts with two decimal places, such as $0.00, $03.23, $3.14, $9.99, $1234.56 and so on.